<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
<title><s:property value="#session.titleDesc"/></title>
<%@ include file="/common/meta.jsp"%>
<SCRIPT type="text/javascript">
<!--	
	function ncProduct(id, ruleId) {
		var urlpath = $("#context_path").val() + "/product/product!startProductNc.action";
		var subButtom = '#ncButtom' + id;
		$(subButtom).hide();
		$.post(urlpath, { "product.id":id, "product.ruleId":ruleId },
			function(data){
				$(subButtom).show();
				alert(data);
			},"text");
	}
	function synProduct(id) {
		var subButtom = '#synButtom' + id;
		var urlpath = $("#context_path").val() + "/product/product!startProductSyn.action";
		$(subButtom).hide();
		$.post(urlpath, { "product.id":id},
			function(data){
				$(subButtom).show();
				alert(data);
			},"text");
	}
//-->
</SCRIPT>
</head>
<body>
<%@ include file="/common/center-top.jsp"%>
<input type="hidden" id="context_path" value="${ctp}"/>
<!-- 网页主显示区，填写表单 -->
<s:form action="/product/product!productList.action" name="mainForm" id="mainForm">
	<table class="tableFromBase" align="center" cellpadding="0" cellspacing="1">
		<tr>
			<td class="tdLabel">类目ID</td>
			<td class="tdInput"><s:textfield name="product.categoryId"></s:textfield></td>
			<td class="tdLabel">产品名称</td>
			<td class="tdInput"><s:textfield name="product.name"></s:textfield></td>
			<td class="tdLabel">语言</td>
			<td class="tdInput">
				<s:select list="langs" listKey="id" listValue="name" name="product.langId"></s:select>
			</td>
		</tr>
		<tr>
			<td class="tdLabel">是否采集</td>
			<td class="tdInput" colspan="5">
				<s:if test="product.ncStatus == 0">
					<input type="radio" name="product.ncStatus" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.ncStatus" checked="checked" value="0" style="width:30px;"/>未采集
					<input type="radio" name="product.ncStatus" value="1" style="width:30px;"/>采集中
					<input type="radio" name="product.ncStatus" value="2" style="width:30px;"/>采集成功
					<input type="radio" name="product.ncStatus" value="3" style="width:30px;"/>采集失败
				</s:if>
				<s:elseif test="product.ncStatus == 1">
					<input type="radio" name="product.ncStatus" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.ncStatus" value="0" style="width:30px;"/>未采集
					<input type="radio" name="product.ncStatus" checked="checked" value="1" style="width:30px;"/>采集中
					<input type="radio" name="product.ncStatus" value="2" style="width:30px;"/>采集成功
					<input type="radio" name="product.ncStatus" value="3" style="width:30px;"/>采集失败
				</s:elseif>
				<s:elseif test="product.ncStatus == 2">
					<input type="radio" name="product.ncStatus" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.ncStatus" value="0" style="width:30px;"/>未采集
					<input type="radio" name="product.ncStatus" value="1" style="width:30px;"/>采集中
					<input type="radio" name="product.ncStatus" checked="checked" value="2" style="width:30px;"/>采集成功
					<input type="radio" name="product.ncStatus" value="3" style="width:30px;"/>采集失败
				</s:elseif>
				<s:elseif test="product.ncStatus == 3">
					<input type="radio" name="product.ncStatus" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.ncStatus" value="0" style="width:30px;"/>未采集
					<input type="radio" name="product.ncStatus" value="1" style="width:30px;"/>采集中
					<input type="radio" name="product.ncStatus" value="2" style="width:30px;"/>采集成功
					<input type="radio" name="product.ncStatus" checked="checked" value="3" style="width:30px;"/>采集失败
				</s:elseif>
				<s:else>
					<input type="radio" name="product.ncStatus" checked="checked" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.ncStatus" value="0" style="width:30px;"/>未采集
					<input type="radio" name="product.ncStatus" value="1" style="width:30px;"/>采集中
					<input type="radio" name="product.ncStatus" value="2" style="width:30px;"/>采集成功
					<input type="radio" name="product.ncStatus" value="3" style="width:30px;"/>采集失败
				</s:else>
			</td>
		</tr>
		<tr>
			<td class="tdLabel">是否同步</td>
			<td class="tdInput" colspan="5">
				<s:if test="product.synStatus == 0">
					<input type="radio" name="product.synStatus" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.synStatus" checked="checked" value="0" style="width:30px;"/>未同步
					<input type="radio" name="product.synStatus" value="1" style="width:30px;"/>同步中
					<input type="radio" name="product.synStatus" value="2" style="width:30px;"/>同步成功
					<input type="radio" name="product.synStatus" value="3" style="width:30px;"/>同步失败
				</s:if>
				<s:elseif test="product.synStatus == 1">
					<input type="radio" name="product.synStatus" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.synStatus" value="0" style="width:30px;"/>未同步
					<input type="radio" name="product.synStatus" checked="checked" value="1" style="width:30px;"/>同步中
					<input type="radio" name="product.synStatus" value="2" style="width:30px;"/>同步成功
					<input type="radio" name="product.synStatus" value="3" style="width:30px;"/>同步失败
				</s:elseif>
				<s:elseif test="product.synStatus == 2">
					<input type="radio" name="product.synStatus" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.synStatus" value="0" style="width:30px;"/>未同步
					<input type="radio" name="product.synStatus" value="1" style="width:30px;"/>同步中
					<input type="radio" name="product.synStatus" checked="checked" value="2" style="width:30px;"/>同步成功
					<input type="radio" name="product.synStatus" value="3" style="width:30px;"/>同步失败
				</s:elseif>
				<s:elseif test="product.synStatus == 3">
					<input type="radio" name="product.synStatus" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.synStatus" value="0" style="width:30px;"/>未同步
					<input type="radio" name="product.synStatus" value="1" style="width:30px;"/>同步中
					<input type="radio" name="product.synStatus" value="2" style="width:30px;"/>同步成功
					<input type="radio" name="product.synStatus" checked="checked" value="3" style="width:30px;"/>同步失败
				</s:elseif>
				<s:else>
					<input type="radio" name="product.synStatus" checked="checked" value="-1" style="width:30px;"/>全部
					<input type="radio" name="product.synStatus" value="0" style="width:30px;"/>未同步
					<input type="radio" name="product.synStatus" value="1" style="width:30px;"/>同步中
					<input type="radio" name="product.synStatus" value="2" style="width:30px;"/>同步成功
					<input type="radio" name="product.synStatus" value="3" style="width:30px;"/>同步失败
				</s:else>
			</td>
		</tr>
		<tr>
			<td class="tdInput" colspan="6" align="center" style="text-align: center;">
				<img src="${ctp}/images/cx.gif" onclick="mainForm.submit();" style="cursor: pointer;"/>
			</td>
		</tr>
	</table>
</s:form>
<table class="tableList" cellspacing="1" cellspacing="0" cellpadding="0">
	<tr>
		<th>名称</th>
		<th>采集时间</th>
		<th>采集状态</th>
		<th>同步时间</th>
		<th>同步状态</th>
		<th>操作</th>
	</tr>
	<s:iterator value="productPage.result" var="uvar">
		<tr>
			<td>${uvar.name}</td>
			<td>${uvar.ncTime}</td>
			<td>
				<s:if test="%{#uvar.ncStatus == 0}">未采集</s:if>
				<s:elseif test="%{#uvar.ncStatus == 1}"><font color="yellow">采集中</font></s:elseif>
				<s:elseif test="%{#uvar.ncStatus == 2}"><font color="green">采集成功</font></s:elseif>
				<s:elseif test="%{#uvar.ncStatus == 3}"><font color="red">采集失败</font></s:elseif>
				<s:else>未知</s:else>
			</td>
			<td>${uvar.synTime}</td>
			<td>
				<s:if test="%{#uvar.synStatus == 0}">未同步</s:if>
				<s:elseif test="%{#uvar.synStatus == 1}"><font color="yellow">同步中</font></s:elseif>
				<s:elseif test="%{#uvar.synStatus == 2}"><font color="green">同步成功</font></s:elseif>
				<s:elseif test="%{#uvar.synStatus == 3}"><font color="red">同步失败</font></s:elseif>
				<s:else>未知</s:else>
			</td>
			<td>
				<a target="_blank" href="${ctp}/product/product!productInfo.action?product.id=${uvar.id}">查看商品</a>
				<s:if test="%{#uvar.ncStatus != 1}">
				|
				<span id="ncButtom${uvar.id}" onclick="ncProduct('${uvar.id}', '${uvar.ruleId}');" style="cursor: pointer;">采集</span>
				</s:if>
				<s:if test="%{#uvar.synStatus != 1}">
				|
				<span id="synButtom${uvar.id}" onclick="synProduct('${uvar.id}');" style="cursor: pointer;">同步</span>
				</s:if>
			</td>
		</tr>
	</s:iterator>
</table>
<cus:page pageBean="productPage" action="/product/product!productList.action" cssClass="scott" paramsKey="product.categoryId,product.name,product.langId,product.ncStatus,product.synStatus"></cus:page>
<%@ include file="/common/center-down.jsp"%>				
</body>
</html>